home *** CD-ROM | disk | FTP | other *** search
- ===========================================================================
- BBS: The Abacus * HST/DS * Potterville MI
- Date: 06-12-93 (11:07) Number: 264
- From: BILL LINDSAY Refer#: NONE
- To: ALL Recvd: NO
- Subj: Keyboard info 1/ Conf: (36) C Language
- ---------------------------------------------------------------------------
- /*
- Several people of late have requested code to determine keyboard
- information. Here is some code that displays bios information
- to the user. scope: IBM compatible PC compatible bios '86 type
- processor.
- */
- /* This code hereby consigned to the */
- /* public domain by Bill Lindsay, this */
- /* june 12. 1993. */
-
-
- #include <dos.h>
- #include <stdio.h>
-
- int board_type ();
- int wait_for_key ();
- void get_the_key (char *keys, unsigned char *togl);
-
- union REGS intregs;
- int is_enhanced = 1; /* board_type() changes this to 0 if */
- /* keyboard is not enhanced. */
-
- main()
- {
- unsigned char codes[2]; /* codes[0] = scancode */
- /* codes[1] = character */
- unsigned char shift[2]; /* shift[] = shift status */
- unsigned char mask;
- int i;
-
- char *togles1[] =
- {"r-Sh","l-Sh","Ctrl","Alt_","Scrl","Num_","CAPS","Ins_"};
-
- char *togles2[] = {"\b\bl-","\b\br-"};
-
- is_enhanced = board_type ();
-
- do {
- get_the_key (codes, shift); /* Return by reference */
- printf ("Scancode == \'\\x%02X\'. ", (int) codes[0]);
-
- printf ("Character == \'%c\'. ascii \'\\x%02X\'.\n",
- (codes[1] == '\x0d') ? (' ') : (codes[1]),
- (int) codes[1]);
- for (i=7, mask = '\x01'; i >= 0; i--) {
- if (i == 2)
- { /* left or right Ctrl */
- printf("%s",((shift[1] & '\x01') ?
- (togles2[0]) :
- (shift[1] & '\x04') ?
- (togles2[1]) : ("")));
- }
-
- else if (i == 3)
- { /* left or right Alt */
- printf("%s",((shift[1] & '\x02') ?
- (togles2[0]) :
- (shift[1] & '\x08') ?
- (togles2[1]) : ("")));
- }
- printf ("%s____", (shift[0] & (mask << i)) ?
- (togles1[i]) : ("____"));
- } /* for loop */
-
- printf ("\nKeyboard is%s enhanced. \"Q\" to quit.\n\n",
- (is_enhanced) ? ("") : (" not"));
-
- }while (!(toupper(codes[1]) == 'Q'));
- exit(0);
- }
- ___----------------------------8<------------------------------------
- >>> Continued to next message
-
- * SLMR 2.1a *
-
- --- Maximus 2.01wb
- * Origin: LIFELINE BBS - Edmonton, Ab, Canada! V32b (403)481-4977 (1:342/51)
- SEEN-BY: 1/211 11/2 4 13/13 101/1 108/89 109/25 110/69 114/5 123/19 124/1
- SEEN-BY: 153/752 154/40 77 157/110 159/100 125 430 575 950 203/23 209/209
- SEEN-BY: 261/1023 280/1 390/1 396/1 5 15 2270/1 2430/1 2440/5 3603/20
-